<?php defined('IN_YuLin') || exit('NO PERMIT!'); ?>
{template index/header}
<script  src="static/js/artDialog/artDialog.source.js?skin=blue"></script>
<script src="static/js/artDialog/plugins/iframeTools.source.js"></script>
<script src="static/js/ajaxfileupload.js"></script>
<style>
.boxlist li label
  { border: 1px solid #d3dbde;
    border-radius: 3px;
    color: #666;
    cursor: pointer;
    display: inline-block !important;
    float: left !important;
    width: 63px !important;
    text-align: center;
    background:#f2f3f5; 
}
.boxlist li label:hover
  {
	background:#03a9f4;
  	color:#fff; 
  }
a{cursor: pointer;}
.upload{
	
	width:100%;
	float:left;
}
.upload select{
	width:100px;
	float:left;
	margin-left:12px;
}
.upload  input{
	background:#ddd;
}
</style>
    <div class="subnav">
    	<a href="">首页</a> &gt; <a href="">系统管理</a> &gt; 首页轮播
    </div>
		 
	<div class="main-inner">
		<div class="x-body">
			<div class="formlist" style="border:0px;">
			<form action="?m=system&c=indexbanner" method="post" id="frm_logo">
				<div class="formbox">
					<h5>PC轮播海报</h5>
					<ul class="boxlist">
					
					{loop $pc_arr as $k=>$v}
						<li class="fix">
							<div class="upload" >
								  <input type="hidden" name="logo[{$k}][type]" value="1">
								    <input type="text" class="w300"  id="logo_{$k}" value="{$v[bn_pic]}"  name="logo[{$k}][pic]" readonly="readonly" >
								 
								<label>
									上传<input style="display:none;" accept="image/*" type="file" name="img_{$k}" id="img_{$k}" onchange="upload_pic({$k});">
								</label>
								<a class="formBtn" style="float:left;" onclick="del_logo({$k});">删除</a>
								<a class="formBtn" style="float:left;" onclick="showPic({$k});">图片预览</a> 
								<select  name="logo[{$k}][url]" onchange="select_pic(this,{$k})"> 
									{loop $pc_page_arr as $k1=>$v1} 
									<option {if $v['bn_code']==$k1} selected {/if} value="{$k1}">{$v1}</option>
									{/loop}
								</select>
								<div  id="ext_{$k}">
								   {if $v[bn_code]=="other"}
    								    <input   name="logo[{$k}][bn_url]" type="text" class="w100" value="{$v[bn_url]}"> <p>* 自定义链接请使用http://或https开头。</p>
    								{/if}
								</div>
							</div>
						</li>						
					{/loop}
						 
					</ul>
					<br>
					<h5>手机轮播海报</h5>
					<ul class="boxlist">
						 {loop $mobile_arr as $k=>$v}
						 <!--{eval $k= $k+4;}-->
						<li class="fix">
							<div class="upload">
							     <input type="hidden" name="logo[{$k}][type]" value="2">
								<input type="text" class="w300" id="logo_{$k}" name="logo[{$k}][pic]" value="{$v[bn_pic]}" readonly="readonly" > 
								<label>
									上传<input style="display:none;" accept="image/*" type="file" name="img_{$k}" id="img_{$k}" onchange="upload_pic({$k});">
								</label>
								<a class="formBtn" style="float:left;" onclick="del_logo({$k});">删除</a>
								<a class="formBtn" style="float:left;" onclick="showPic({$k});">图片预览</a> 
								 
								<select  name="logo[{$k}][url]" onchange="select_pic(this,{$k})"> 
									{loop $mobile_page_arr as $k1=>$v1} 
									<option {if $v['bn_code']==$k1} selected {/if} value="{$k1}">{$v1}</option>
									{/loop}
								</select>
								<div  id="ext_{$k}">
    								  {if $v[bn_code]=="other"}
    								    <input   name="logo[{$k}][bn_url]" type="text" class="w100" value="{$v[bn_url]}"> <p>* 自定义链接请使用http://或https开头。</p>
    								{/if}
								</div>
							</div>
							
						</li>
						{/loop} 
					</ul> 
				</div>
				</form>
				<div style="width:100%;margin-top:60px;float:left;" >
					<a class="formBtn active" href="javascript:void(0);" onclick="save();">提交保存</a>
				</div>
			</div>
			 
		</div>
	</div>
	<script type="text/javascript">
	//选择页面地址
	function select_pic(obj,k){
		var ext_html = '<input  id="pc_ext_url" name="logo['+k+'][bn_url]" type="text" class="w100" > <p>* 自定义链接请使用http://或https开头。</p>';
		
		if($(obj).val()=="other"){
			$("#ext_"+k).html(ext_html);
		}else{
			$("#ext_"+k).html("");
			}
	}
 
	
	//上传图片
	function upload_pic(k){
         /* alert(upload_type); */
		 $.ajaxFileUpload({
		     url: '?m=system&c=upload&type=upload_type&file=img_'+k,
		     fileElementId: 'img_'+k,
		     dataType: 'json',
		     success: function(json){
		    	 if (json.error == "1"){
		    		 art.dialog.tips('图片上传失败'); 
		    	 	}else{
    		    	 	$("#logo_"+k).val(json.url);
		    	 		art.dialog.tips('图片上传成功');
		     		}
		 		}
	 	});
	}

	//图片删除
	function del_logo(k){
		$("#logo_"+k).val("");
	}


	
	//图片预览
    function showPic(k){
        if($("#logo_"+k).val()){
        	art.dialog.open("?m=system&c=views&path="+$("#logo_"+k).val(),{title:'图片预览'});
        }else{
        	art.dialog.tips('请上传图片'); 
        }
    	
     
    }

    //提交保存
    function save(){
		$("#frm_logo").submit();

    }
    		
    </script>		
{template index/footer}
